﻿using System.Collections.Generic;
using System.Windows.Media;
using Red.Controls.Diagrams.Declarators;

namespace Red.Controls.Diagrams.ViewModels
{
    public class DummyConnectorViewModel : ConnectorViewModel
    {
        #region C-tor

        public DummyConnectorViewModel( NodeConnectorDeclarator connectorDeclarator, bool isInherited )
            : base( connectorDeclarator.Name, "", null, isInherited, Colors.White )
        {
            Declarator = connectorDeclarator;
        }

        #endregion C-tor

        #region Properties
        public NodeConnectorDeclarator Declarator { get; }

        public new List<ConnectorMenuItem> ContextMenuItems => new List<ConnectorMenuItem> { new RemoveDummyConnectorMenuItem( this ) }; 

        public new string Name
        {
            get { return Declarator.Name; }
            set 
            {
                if ( Declarator.Name != value )
                {
                    Declarator.Name = value;
                    OnPropertyChanged();
                }
            }
        }

        public string Binding
        {
            get { return Declarator.Binding; }
            set 
            {
                if ( Declarator.Binding != value )
                {
                    Declarator.Binding = value;
                    OnPropertyChanged();
                }
            }
        }

        #endregion Properties
    }

    public class RemoveDummyConnectorMenuItem : ConnectorMenuItem
    {
        public DummyConnectorViewModel Connector { get; private set; }

        public RemoveDummyConnectorMenuItem( DummyConnectorViewModel connector )
        {
            Connector = connector;
            Header = "Remove";
        }
    }
}
